<%--

  Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the latest version of the GNU Lesser General
  Public License as published by the Free Software Foundation;

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with this program (LICENSE.txt); if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

--%>
<%@ page errorPage="/WEB-INF/jsp/error.jsp"
    contentType="text/html; charset=utf-8"
%>
<%@ page pageEncoding="utf-8"%> 
<%@ page import="org.jamwiki.model.*,org.jamwiki.utils.*,java.util.*,org.jamwiki.WikiBase" %> 
<%request.setCharacterEncoding("utf-8");%> 
<%
     String server = request.getServerName();
     int port = request.getServerPort();
     String hostport = "http://"+server+":"+port;
     String topicId = (String)request.getAttribute("topic_id");
     String topic_Id = (String)request.getAttribute("topicId");
     if(topic_Id==null){
    	 topic_Id = "0";
     }
     String auditStatus = (String)request.getAttribute("auditStatus");
     String size = (String)request.getAttribute("size");
     boolean show = false;
     if("true".equals(request.getParameter("show"))||request.getParameter("show")==null)
          show = true;
 %>
 <script type="text/javascript">
<!--
 function creatNew(namepath,categoryId){
     //var strFeatures='top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no';
     //alert(namepath);
     var urlparam="<%=hostport%>/jamwiki/ntko/edit.jsp?namepath="+encodeURI(namepath)+"&categoryId="+categoryId; 
     //window.open(urlparam,'新建文档',strFeatures);
     openwindow(urlparam,'','','');
 }
 
  function viewNew(namepath,categoryId){
     //var strFeatures='top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no';
     //alert(namepath);
     var urlparam="<%=hostport%>/jamwiki/ntko/view.jsp?namepath="+encodeURI(namepath)+"&categoryId="+categoryId; 
     //window.open(urlparam,'新建文档',strFeatures);
     openwindow(urlparam,'','','');
 }
 
 function publicTopic(){
     form1.action="<%=request.getContextPath()%>/en/Special:CreateTopic?actionType=public&topicId=<%=topicId%>";
     form1.submit();
 
 }
 
 var show=true;
function showCatalogList()
{
   
    show=!show;
    var divCatalogList=document.getElementById("code");
    if(divCatalogList!=null){
        divCatalogList.style.display = show ? "none" : "";
    }
}
//-->
</script>
<style>
<!--
.f_top{
 margin:0px auto; height:8px; padding-top:5px; clear:both
}
.f_content{
   margin:0px auto; padding-left:0px; clear:both
 }
.f_content .Find{ DISPLAY: block; height:20px; padding-bottom:5px; margin-bottom:3px}
.f_content .Find1{ font-size: 12px;padding-top:2px}
.f_content .Find div{ padding-left:5px;float:left;}
.f_content .Find2{}
.f_bottom{
 margin:0px auto; height:8px; clear:both
}
-->
</style>

 <%
  List list = WikiBase.getDataHandler().getCommentByTopicId(Integer.parseInt(topic_Id));
%>
<%@ page import="org.jamwiki.model.*,org.jamwiki.utils.*" %>

 
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <td width="0" class="word-orange" align="center"><%@ include file="navigation-menu.jsp" %></td>   
           </tr>  
      </table>
     <table width="98%" id="top" height="8" border="0" cellpadding="0" cellspacing="0">
       <tr>
         <td><%@ include file="top-menu.jsp" %></td>
       </tr>
     </table>
     
     <table width="98%"><tr><td>
         <!-- 主题不存在 -->
		 <c:if test="${empty notopic}">
		 <!-- 主题不为空 -->
	     <c:if test="${!empty topicObject}">
		<div id="content-article">
		<!-- 图片类型 -->
		<c:if test="${topicImage}"><jamwiki:image value="${topicObject.name}" /></c:if>
	
		
		<!-- 非文件类型 -->
		
		<c:if test="${!topicFile}">
		<table  width="98%" border="0" cellspacing="0" cellpadding="0">
		<tr><td align="center"  colspan="3"><c:out value="${topicObject.name}"/></td></tr>
		<tr><td width="30%">&nbsp;</td><td width="30%">&nbsp;</td><td align="right" width="38%">发布时间：<c:out value="${topicObject.createDate}"/> 发布人：<c:out value="${topicObject.author}"/></td></tr>
		<tr><td align="left" colspan="3"><c:out value="${topicObject.topicContent}" escapeXml="false" /></td></tr>
		</table>
		<div id="divCatalog">
        <div class="f_content">
            <div align="left" id='divCatalogList'>
						<table width="98%" border="0" cellspacing="0" cellpadding="0" >
						    <tr><td align="right"><a href="#" onclick="showCatalogList();" style="color:blue">共（ <%=size %> ）条评论</a></td></tr>
							<tr>
								<td>
									<div id='hade' style="display: none">
									</div>
									<% if(show){ %>
									  <div id='code'style="display: none">
									<%}else{ %>
									  <div id='code'style="">
									<%} %>
									<table width="100%">
										 <% for(int i=0;i<list.size();i++){ 
											 Comment comment =(Comment) list.get(i);
										 %>
					                     <tr><td colspan="4"> <hr/></td></tr>
										 <tr><td width="30%"><%=i+1%>： <%=comment.getCommentDate()%></td><td  width="30%">评论人：<%=comment.getUserName()==null?"匿名":comment.getUserName()%></td><td  width="40%">IP：<%=comment.getIpAddress()%></td><td><a href="#top">TOP</a></td></tr>
										 <tr><td colspan="4"><%=comment.getCommentInfo()%></td></tr>
										 <%} %>
										 <tr><td colspan="3">
										 <fieldset>
												<legend>编辑面板</legend>	
												<form name="form" method="post" name="editform" action="<jamwiki:link value="${topicObject.name}" />">
												
												<p>
												<textarea name="contents" rows="5" cols="200" accesskey=","></textarea>
												</p>
												<input type="hidden" name="topic" value="<c:out value="${topicObject.name}"/>" />
												<input type="hidden" name="editComment" value="comment" size="60" id="editComment" />
												<input type="hidden" name="topicId" value="<%=topic_Id %>" />
												<p align="right">
												<input type="submit" name="save" value="提交评论"  accesskey="s"/>
												</p>
												</form>
												</fieldset>
										 </td></tr>
										 
										 </table>
									</div>
								</td>
							</tr>
						</table>
			</div>
        </div>
        </div>
		</c:if>
		</div>
		
		
	   <c:if test="${!empty fileVersions}">
		
		 <table width="100%"  border="0"  cellpadding="0" cellspacing="1" bgcolor="#dddddd">
			 <tr><td width="10%" class="table-title">版本号</td><td width="4%" class="table-title"></td><td width="21%" class="table-title">主题名称</td><td width="20%" class="table-title">发布人</td><td width="17%" class="table-title">发布时间</td><td width="18%" class="table-title">文件大小</td><td width="20%" class="table-title">操作</td></tr>
		 <c:forEach items="${fileVersions}" var="fileVersion">

          <tr class="table-tr1">
            <td width="10%">版本【<c:out value="${fileVersion.fileVersionId_display}" />】</td>
            <td width="4%" height="25" align="center" bgcolor="#FFFFFF" class="table-tr1"><img src="<%=request.getContextPath() %>/images/Forum_readme.gif" width="10" height="10"></td>
            <td width="21%" align="left" bgcolor="#FFFFFF" class="table-tr1"><a href="#" onclick="viewNew('${fileVersion.url}','${categoryId}')"><c:out value="${topicObject.simpleName}" /></a></td>
            <td width="20%" align="center" bgcolor="#FFFFFF" class="table-tr1"><c:out value="${topicObject.author}" /> </td>
            <td width="17%" align="center" bgcolor="#FFFFFF" class="table-tr1"><f:formatDate value="${fileVersion.uploadDate}" type="both" pattern="yyyy-MM-dd" /></td>
            <td width="18%" align="center" bgcolor="#FFFFFF" class="table-tr1"><c:out value="${fileVersion.fileSize}" /> 字节</td>
            <td width="20%" align="center" bgcolor="#FFFFFF" class="table-tr1"><%if("1".equals(auditStatus)&&ServletUtil.isLogin()){ %> <a href="#" onclick="creatNew('${fileVersion.url}','${categoryId}')" >编辑</a><%}else{ %>编辑<%} %></td>
          </tr>
     
		 </c:forEach> 
		 </table>
        <br/>
		<div id="divCatalog">
        <div class="f_content">
            <div align="left" id='divCatalogList'>
						<table width="98%" border="0" cellspacing="0" cellpadding="0" >
						    <tr><td align="right"><a href="#" onclick="showCatalogList();" style="color:blue">共（ <%=size %> ）条评论</a></td></tr>
							<tr>
								<td>
									<div id='hade' style="display: none">
									</div>
									<% if(show){ %>
									  <div id='code'style="display: none">
									<%}else{ %>
									  <div id='code'style="">
									<%} %>
									<table width="100%">
										 <% for(int i=0;i<list.size();i++){ 
											 Comment comment =(Comment) list.get(i);
										 %>
					                     <tr><td colspan="4"> <hr/></td></tr>
										 <tr><td width="30%"><%=i+1%>： <%=comment.getCommentDate()%></td><td  width="30%">评论人：<%=comment.getUserName()==null?"匿名":comment.getUserName()%></td><td  width="40%">IP：<%=comment.getIpAddress()%></td><td><a href="#top">TOP</a></td></tr>
										 <tr><td colspan="4"><%=comment.getCommentInfo()%></td></tr>
										 <%} %>
										 <tr><td colspan="3">
										 <fieldset>
												<legend>编辑面板</legend>	
												<form name="form" method="post" name="editform" action="<jamwiki:link value="${topicObject.name}" />">
												
												<p>
												<textarea name="contents" rows="5" cols="200" accesskey=","></textarea>
												</p>
												<input type="hidden" name="topic" value="<c:out value="${topicObject.name}"/>" />
												<input type="hidden" name="editComment" value="comment" size="60" id="editComment" />
												<input type="hidden" name="topicId" value="<%=topic_Id %>" />
												<p align="right">
												<input type="submit" name="save" value="提交评论"  accesskey="s"/>
												</p>
												</form>
												</fieldset>
										 </td></tr>
										 
										 </table>
									</div>
								</td>
							</tr>
				   </table>
			</div>
        </div>
        </div>
		 </c:if>
				</c:if>
			</c:if>
		<c:if test="${!empty notopic}">
		<div class="message"><f:message key="${notopic.key}"><f:param value="${notopic.params[0]}" /><f:param><jamwiki:link value="${notopic.params[0]}" text="${notopic.params[0]}" /></f:param></f:message></div>
		</c:if>
		</td></tr></table>
 
